<template>
  <div class="h-panel">
    <PaasTitleBar></PaasTitleBar>
    <div class="h-panel-body bottom-line">
      <Form ref="form" :validOnChange="true" :showErrorTip="true" labelPosition="true" :labelWidth="110" :rules="vRules" :model="model" mode="twocolumn">
        <FormPageSelect label="支持按钮" prop="buttonIds" :of="menuId" v-model="model.buttonIds" url="/sysmenus/menuselect" :multiple="true"></FormPageSelect>
      </Form>
    </div>
    <PaasButtonBar></PaasButtonBar>
  </div>
</template>
<script>
export default {
  async mounted() {
    let id = this.$route.query.id;

    if (!!id) {
      this.menuId = id.split("&")[1];
      this.model = await this.$store.dispatch("getFormData", id);
      if (!!this.model.buttonIds && this.model.buttonIds.indexOf(",") != -1) {
        this.model.buttonIds = this.model.buttonIds.split(",");
      }
    }
  },
  data() {
    return {
      menuId: "",
      model: {
        buttonIds: "",
      },
      vRules: {
        required: ["buttonIds"],
      },
    };
  },
  methods: {
    validate() {
      this.model.buttonIds = this.model.buttonIds.join(",");
    },
  },
  deactivated() {
    this.$destroy(true);
  },
};
</script>